package com.ruoyi.system.controller.car4s_controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.car4s_domain.Car4sAppointmentInfo;
import com.ruoyi.system.service.car4s_service.ICar4sAppointmentInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约信息Controller
 * 
 * @author LK
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/system/car_4s_appointment_info")
public class Car4sAppointmentInfoController extends BaseController
{
    @Autowired
    private ICar4sAppointmentInfoService car4sAppointmentInfoService;

    /**
     * 查询预约信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_appointment_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(Car4sAppointmentInfo car4sAppointmentInfo)
    {
        startPage();
        List<Car4sAppointmentInfo> list = car4sAppointmentInfoService.selectCar4sAppointmentInfoList(car4sAppointmentInfo);
        return getDataTable(list);
    }

    /**
     * 导出预约信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_appointment_info:export')")
    @Log(title = "预约信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Car4sAppointmentInfo car4sAppointmentInfo)
    {
        List<Car4sAppointmentInfo> list = car4sAppointmentInfoService.selectCar4sAppointmentInfoList(car4sAppointmentInfo);
        ExcelUtil<Car4sAppointmentInfo> util = new ExcelUtil<Car4sAppointmentInfo>(Car4sAppointmentInfo.class);
        util.exportExcel(response, list, "预约信息数据");
    }

    /**
     * 获取预约信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_appointment_info:query')")
    @GetMapping(value = "/{appointmentInfoId}")
    public AjaxResult getInfo(@PathVariable("appointmentInfoId") Long appointmentInfoId)
    {
        return success(car4sAppointmentInfoService.selectCar4sAppointmentInfoByAppointmentInfoId(appointmentInfoId));
    }

    /**
     * 新增预约信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_appointment_info:add')")
    @Log(title = "预约信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Car4sAppointmentInfo car4sAppointmentInfo)
    {
        return toAjax(car4sAppointmentInfoService.insertCar4sAppointmentInfo(car4sAppointmentInfo));
    }

    /**
     * 修改预约信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_appointment_info:edit')")
    @Log(title = "预约信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Car4sAppointmentInfo car4sAppointmentInfo)
    {
        return toAjax(car4sAppointmentInfoService.updateCar4sAppointmentInfo(car4sAppointmentInfo));
    }

    /**
     * 删除预约信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_appointment_info:remove')")
    @Log(title = "预约信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appointmentInfoIds}")
    public AjaxResult remove(@PathVariable Long[] appointmentInfoIds)
    {
        return toAjax(car4sAppointmentInfoService.deleteCar4sAppointmentInfoByAppointmentInfoIds(appointmentInfoIds));
    }
}
